import QtQuick 2.15

Item {
    id: cSnakeBar
    anchors.horizontalCenter:{
       if(parent)
       {
           return parent.horizontalCenter
       }
    }
    y: 0//( parent ) ? ( parent.height - height ) : ( 0 )
    width: label.contentWidth + 50
    height: label.contentHeight + 30

    property alias text: label.text

    BorderImage {
        x: -18
        width: parent.width + 18 + 19
        height: parent.height + 41
        border.left: 25
        border.right: 25
        border.top: 5
        border.bottom: 50
        source: "qrc:/images/control/Frame.png"
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true
    }

    TextEdit {
        id: label
        x: 25
        y: 20
        enabled: false
        width: 400
        wrapMode: TextEdit.Wrap
    }

    SequentialAnimation {
        running: true

        NumberAnimation {
            target: cSnakeBar
            property: "y"
            to:  30
            easing.type: Easing.OutQuad
            duration: 250
        }
    }

    SequentialAnimation {
        running: !mouseArea.containsMouse

        PauseAnimation {
            duration: 5000
        }

        ParallelAnimation {

            NumberAnimation {
                target: cSnakeBar
                property: "opacity"
                to: 0
                duration: 250
            }

            NumberAnimation {
                target: cSnakeBar
                property: "scale"
                to: 0.8
                easing.type: Easing.InQuad
                duration: 250
            }
        }

        ScriptAction {

            script: {
                cSnakeBar.destroy();
            }
        }
    }
}
